<?php

class PublicAction extends CommonAction
{
	
	public function onLogin() {
		$_rdata = A('Login', 'user')->_onLogin();
		$_rdata['status'] ? $this->success($_rdata['msg']) : $this->error($_rdata['msg']);
		exit;
	}
	
	public function onajaxLogin() {
		$_rdata = A('Login', 'user')->_onLogin();
		if(($_rdata['status'] == 1) && $_REQUEST['key']){
			A('Gold')->loginToAddGold();
		}
		die(json_encode($_rdata));
	}
	
	public function onLogout(){
		$_rdata = A('Logout', 'user')->_onLogout();
		$_rdata['status'] ? $this->success($_rdata['msg']) : $this->error($_rdata['msg']);
		exit;
	}
	
	public function onRegister(){
		$_rdata = A('Register', 'user')->_onRegister();
		$_rdata['status'] ? $this->success($_rdata['msg']) : $this->error($_rdata['msg']);
		exit;
		
	}
	
	public function onModify(){
		$_description = array('1' => '修改成功', '-1' => '未登录', '-2' => '密码重复错误', '-3' => '数据库错误');
		if(!$this->Core->User->u_id){
			$result = -1;
		}else{
			$result = D('User')->modify($this->Core->User->u_id);
		}
		$_rdata = array('status'=> $result, 'msg'=>$_description[$result]);
		die(json_encode($_rdata));
	}
	
		

}
?>